﻿<UserControl x:Class="Northwind.UI.WPF.CustomerSearchBoxView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <StackPanel>   
        <ListBox ItemsSource="{Binding Customers}"
                 SelectedValuePath="CustomerID"
                 SelectedItem="{Binding SelectedCustomer}"
                 HorizontalAlignment="Left"
                 Height="180"
                 Width="250">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <ContentControl>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="MouseDoubleClick">
                                <cmd:EventToCommand Command="{Binding 
                                            ShowCustomerDetailsCommand}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <TextBlock Text="{Binding CompanyName}" />
                    </ContentControl>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.Resources>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                </Style>
            </ListBox.Resources>
        </ListBox>
    </StackPanel>
</UserControl>
